package com.chen.shopping_order_service.listener;

import com.chen.shopping_common.pojo.Orders;
import com.chen.shopping_common.service.OrderService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@RocketMQMessageListener(topic = "check_orders_queue",consumerGroup = "check_orders_queue")
public class OrderListener implements RocketMQListener<String> {

    @Autowired
    private OrderService orderService;


    @Override
    public void onMessage(String id) {
        //查询订单
        Orders orders = orderService.findById(id);
        //查询订单状态
        if (orders.getStatus() == 1){
            orders.setStatus(6);
            orderService.update(orders);
        }
    }
}